package com.webdemo9.dao.impl;

import java.io.InputStream;
import java.util.Properties;

import com.webdemo9.dao.DBDao;

public class DBDaoFactory {
	
	private static Properties p = null;
	
	static {
		try {
			InputStream in = DBDaoFactory.class.
					getClassLoader().getResourceAsStream("daoproperties.properties");
			p = new Properties();
			p.load(in);
		} catch(Exception e) {
			throw new RuntimeException(e);
		}
		
	}
	
	public static DBDao getDBDao() {
		DBDao dbDao = null;
		String className = p.getProperty("com.webdemo9.dao.DBDao");
		try {
			Class<?> clazz = Class.forName(className);
			dbDao = (DBDao)clazz.newInstance();
		} catch(Exception e) {
			throw new RuntimeException(e);
		}
	
		
		return dbDao;
	}
}
	